package TempPackage;

import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Set;
import java.util.Stack;
import java.util.Vector;

import edu.uci.ics.jung.algorithms.scoring.PageRank;
import Config.Configure;
import Config.GlobalLog;
import EurekaAnalyzer.IDInformation;
import EurekaProcessor.PipelineMgr;
import EurekaProcessor.PreProcessor;
import EurekaProcessor.ProcessorMgr;
import GUI.DataFrontier;
import Statistics.IDGraphNode;
import Statistics.TarjanSCC;
import Statistics.IDGraphToJungGraph.MyEdge;
import Store.StoreManager;

public class FileAnalysis {
	private static String path = "./TestData/TestIDInforProcessor/bbstcon.php";
	private static String database = "./TestData/TestIDInforProcessor/Database";
	private static String filebuffer = "";
	private static String id_traits = "发信人: ";
	private static String time_traits = "发信站: 北大未名站 \\(";
	private static String uri_traits = "本文链接: <a href='";
	private static String e_traits = " ";
	
	private static String preProcessor_base = "./TestData/TestPreProcessor/TestData";
	private static String preProcessor_des  = "./TestData/TestPreProcessor/OutputData";
	
	public static void main(String[] args) throws Exception
	{
		
		/*
		FileAnalyzer fa = new FileAnalyzer(path,id_traits,time_traits,uri_traits);
		
		Vector<String> ids = fa.GetAllInfoByTraits(id_traits,e_traits);
		for(String id:ids)
		System.out.println(id);
		System.out.println("Board="+fa.GetBoard());
		System.out.println("URI="+fa.GetUri());
		
		
		IDInfoProcessor idip = new IDInfoProcessor(path,database);
		idip.run();
		*/
		/*
		IDInformation idi = idip.GetIDInformationByID("wsl");
		if (idi != null) {
			System.out.println("Occurence in board Single: "
					+ idi.GetAppearanceByBoard("Single"));
			System.out.println("Reply Count: " + idi.GetReplyCnt());
			System.out.println("Friends Count: "+idi.GetFriendCount());
			idi.ShowFriends();
		}
		*/
		/*
		System.out.println("Now from Database...");
		IDInformation idi2 = idip.GetIDInformationFromDBByID("wsl");
		if (idi2 != null) {
			System.out.println("Occurence in board Single: "
					+ idi2.GetAppearanceByBoard("Single"));
			System.out.println("Reply Count: " + idi2.GetReplyCnt());
			System.out.println("Friends Count: "+idi2.GetFriendCount());
			idi2.ShowFriends();
		}
		*/
		
		String filePath = "./configure_bak";

		/*
		PreProcessor preP = new PreProcessor();
		preP.StartSearch();
		*/
		
		ProcessorMgr pMgr = new ProcessorMgr(filePath);
		//pMgr.Process();

		
		TarjanSCC.CalculateSCC(new DataFrontier().GetIDGraph());
		
		//PageRank<String, MyEdge> pr = new PageRank<String, MyEdge>(dataFrontier.GetJungFormatGraph(), 0.25);
		//pr.evaluate();
		//System.out.println(pr.getVertexScore("wsl"));
       
		/*
		PipelineMgr pMgr = new PipelineMgr(filePath);
		pMgr.Process();
		
		StoreManager sMgr = new StoreManager(Configure.DATABASE_DIR, Configure.GRAPH_DB_DIR);
		HashMap<String, IDGraphNode> graph = sMgr.GetIDGraphData();
		Set<String> keys = graph.keySet();
		Iterator itor = keys.iterator();
		while(itor.hasNext())
		{
			System.out.println((String)itor.next());
		}
		*/
		//DataFrontier ds = new DataFrontier();
		//ds.showGraph();
		/*
		IDInformation idi = pMgr.GetIDInformationByID("wsl");
		if (idi != null) {
			System.out.println("Occurence in board Single: "
					+ idi.GetAppearanceByBoard("Single"));
			System.out.println("Reply Count: " + idi.GetReplyCnt());
			System.out.println("Friends Count: "+idi.GetFriendCount());
			idi.ShowFriends();
		}
		*/
		/*
		FileAnalyzer newfa = new FileAnalyzer(Configure.DEST_DIR+"//multipage//bbstcon.php", id_traits, time_traits,uri_traits);

		Vector<String> newids = newfa.GetAllInfoByTraits(id_traits, e_traits);
		for (String id : newids)
			GlobalLog.AddLog(id);
		System.out.println("Board=" + newfa.GetBoard());
		System.out.println("URI=" + newfa.GetUri());
		*/
	}
}
